package cn.edu.njpi.two;

import java.util.Random;

/**
 * @author 朱宗辉
 * @version V1.0
 * @Package cn.edu.njpi.two
 * @date 2021/7/11 23:20
 */
public class ClientThread extends Thread {
    private final Channel channel;
    private static final Random random = new Random();

    public ClientThread(String name, Channel channel) {
        super(name);
        this.channel = channel;
    }

    @Override
    public void run() {
        try {
            for (int i = 0; true; i++) {
                Request request = new Request(getName(), i);
                channel.putRequest(request);
                Thread.sleep(random.nextInt(1000));
            }
        }catch (Exception e){
        }
    }
}
